.NET Framework Class Library |
BlockingCollection<(Of <(T>)>)..::.TakeFromAny Method (array<BlockingCollection<(Of <(T>)>)>[]()[], T%, CancellationToken) |
BlockingCollection<(Of <(T>)>) Class See Also Send Feedback |
Takes an item from any one of the specified
BlockingCollection<(Of <(T>)>) instances.
A OperationCanceledException is thrown if the CancellationToken is
canceled.
Namespace:
System.Collections.Concurrent
Assembly:
System.Threading (in System.Threading.dll)
Syntax
Visual Basic (Declaration) |
---|
Public Shared Function TakeFromAny ( _ collections As BlockingCollection(Of T)(), _ <OutAttribute> ByRef item As T, _ cancellationToken As CancellationToken _ ) As Integer |
C# |
---|
public static int TakeFromAny( BlockingCollection<T>[] collections, out T item, CancellationToken cancellationToken ) |
Parameters
- collections
- Type: array<
System.Collections.Concurrent..::.BlockingCollection<(Of <(T>)>)
>[]()[]
The array of collections.
- item
- Type:
T
%
The item removed from one of the collections.
- cancellationToken
- Type: System.Threading..::.CancellationToken
A cancellation token to observe.
Return Value
The index of the collection in the collections array from which the item was removed, or -1 if an item could not be removed.Remarks
A call to TakeFromAny may block until an item is available to be removed.
Exceptions
Exception | Condition |
---|---|
System..::.ArgumentNullException | The collections argument is null. |
System..::.OperationCanceledException | If the CancellationToken is canceled. |
System..::.ArgumentException | The collections argument is a 0-length array or contains a null element. |
System..::.ObjectDisposedException | At least one of the BlockingCollection<(Of <(T>)>) instances has been disposed. |
System..::.InvalidOperationException | At least one of the underlying collections was modified outside of its BlockingCollection<(Of <(T>)>) instance. |
System..::.ArgumentOutOfRangeException | The count of collections is greater than the maximum size of 62 for STA and 63 for MTA. |